import Mock from "mockjs";
import servicerEntity from "../model/servicer.entity";

const servicerInstance = new servicerEntity();

// 客服设置
Mock.mock(
  RegExp("/api/servicer/detail" + ".*"),
  "get",
  () => {
    return {
      code: 200,
      msg: 'success',
      data: servicerInstance.findAll(),
    }
  }
);

// 客服设置
Mock.mock(
  RegExp("/mock/api/servicer/config" + ".*"),
  "post",
  (response: any) => {
    let res = JSON.parse(response.body);
    servicerInstance.updateOne('h5', res.h5);
    servicerInstance.updateOne('weapp', res.weapp);
    return Mock.mock({
      code: 200,
      msg: "success",
      data: {},
    });
  }
);
